﻿/*
#**************************************************************************
#  openSIS is a student information system for public and non-public 
#  schools from Open Solutions for Education, Inc. web: www.os4ed.com
#
#  openSIS is  web-based, open source, and comes packed with features that 
#  include student demographic info, scheduling, grade book, attendance, 
#  report cards, eligibility, transcripts, parent portal, 
#  student portal and more.   
#
#  Visit the openSIS web site at http://www.opensis.com to learn more.
#  If you have question regarding this system or the license, please send 
#  an email to info@os4ed.com.
#
#  This program is released under the terms of the GNU General Public License  
#  as  published by the Free Software Foundation, version 2 of the License. 
#  See license.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#**************************************************************************** 

*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenSIS.OpenSISWCFServiceReference;
using System.Data;
using System.Globalization;
using OpenSISInstall;
using OSISToolTip;

namespace OpenSIS.School
{
    public partial class SchoolDetails : System.Web.UI.Page
    {
        // TooltipLang TTL = new TooltipLang();


        protected void Page_Load(object sender, EventArgs e)
        {

            //************** Update on 28/04/2010*************************
            //ddlMinGradeEdit.Style.Add("font-family", "Arial Unicode MS");
            //ddlMaxGradeEdit.Style.Add("font-family", "Arial Unicode MS");
            //************************************************************

            //SchoolBL schoolAdd = new SchoolBL();
            // ServicePropertiesClient schoolAdd = new ServicePropertiesClient();
            TooltipLang TTL = new TooltipLang();
            if (Session["MLCulture"] != null && Session["MLUICulture"] != null)
            {

                TTL.tooltip();
                ibtnAdd.Attributes.Add("onmouseover", "toolTip('" + TTL.Add + "')");
                ibtnAdd.Attributes.Add("onmouseout", "toolTip()");
                imgBtnEdit.Attributes.Add("onmouseover", "toolTip('" + TTL.Edit + "')");
                imgBtnEdit.Attributes.Add("onmouseout", "toolTip()");
                imgBtnEdit.Attributes.Add("onclick", "toolTip('')");
                imgBtnCopy.Attributes.Add("onmouseover", "toolTip('" + TTL.Copy + "')");
                imgBtnCopy.Attributes.Add("onmouseout", "toolTip()");
                imgBtnCopy.Attributes.Add("onclick", "toolTip()");
                imgBtnDelete.Attributes.Add("onmouseover", "toolTip('" + TTL.Delete + "')");
                imgBtnDelete.Attributes.Add("onmouseout", "toolTip()");
                //TTL.tooltip();
                //ibtnAdd.Attributes.Add("onmouseover", "toolTip('Add ')");
                //ibtnAdd.Attributes.Add("onmouseout", "toolTip()");
                //imgBtnEdit.Attributes.Add("onmouseover", "toolTip('Edit')");
                //imgBtnEdit.Attributes.Add("onmouseout", "toolTip()");
                //imgBtnEdit.Attributes.Add("onclick", "toolTip('')");
                //imgBtnCopy.Attributes.Add("onmouseover", "toolTip('Copy')");
                //imgBtnCopy.Attributes.Add("onmouseout", "toolTip()");
                //imgBtnCopy.Attributes.Add("onclick", "toolTip()");
                //imgBtnDelete.Attributes.Add("onmouseover", "toolTip('Delete')");
                //imgBtnDelete.Attributes.Add("onmouseout", "toolTip()");
            }
            addrChk.Attributes.Add("onclick", "CheckSameAddress()");
            chkAddrs.Attributes.Add("onclick", "CheckSameAddressForEdit()");


            if (!IsPostBack)
            {
                try
                {

                    //schoolAdd.propulateState(ref ddlState);
                    //schoolAdd.propulateCountry(ref ddlCountry);
                    //schoolAdd.propulateCountry(ref ddlCountryEdit);

                    //schoolAdd.propulateState(ref ddlPostBoxState);

                    //schoolAdd.propulateCountry(ref ddlPostBoxCountry);
                    //schoolAdd.propulateCountry(ref ddlcountrymledit);

                    //if (Session["SchoolID"] != null)
                    //{
                    //    ddlSchoolName.Items.FindByValue(Session["SchoolID"].ToString()).Selected = true;
                    //}
                    //else
                    //{
                    //    schoolAdd.MaxSchoolID();
                    //    hdnschoolid.Value = schoolAdd.SchoolID.ToString();
                    //    Session["SchoolID"] = schoolAdd.SchoolID.ToString();
                    //    ddlSchoolName.Items.FindByValue(schoolAdd.SchoolID.ToString()).Selected = true;

                    //}
                    //PopulateMasterDropdownFullYear();

                    //schoolAdd.SchoolID = Convert.ToInt32(ddlSchoolName.SelectedItem.Value);
                    ////schoolAdd.propulate(ref ddlMaxGrade);
                    ////schoolAdd.propulate(ref ddlMinGrade);

                    // PupulateSchoolDetailsForView(Convert.ToInt32(ddlSchoolName.SelectedItem.Value));
                    PupulateSchoolDetailsForView(Convert.ToInt32(Session["SchoolID"]));


                    propulateState(ref ddlState);
                    propulateCountry(ref ddlCountry, ref ddlPostBoxCountry);
                    // propulateCountry(ref ddlPostBoxCountry);

                    propulateState(ref ddlPostBoxState);

                    //  propulateCountry(ref ddlPostBoxCountry);
                    //propulateCountry(ref ddlcountrymledit);


                    Multiview1.ActiveViewIndex = 0;

                }
                catch
                {

                }
                finally
                {
                    // schoolAdd = null;
                }
            }
        }

        protected void btnsave_Click(object sender, EventArgs e)
        {

            OpenSISWCFServiceSchoolDetailsClient schoolAdd = new OpenSISWCFServiceSchoolDetailsClient();
            //Function Func = new Function();
            OpenSISWCFServiceGradeLevelClient GLBL = new OpenSISWCFServiceGradeLevelClient();
            OpenSISWCFServiceInstallationClient INBL = new OpenSISWCFServiceInstallationClient();
            SISInstall SISInstall = new SISInstall();
          //  CalExtEndDateEdit.Format = SISInstall.CalenderDateFormat.ToString().Trim();
            try
            {
                string ShortName = txtShortName.Text.Trim().ToString();
                string SchoolName = txtSchoolName.Text.Trim().ToString();
                string Address1 = txtAddress1.Text.Trim().ToString();
                string Address2 = txtAddress2.Text.Trim().ToString();
                string City = txtCity.Text.Trim().ToString();
                int State = Convert.ToInt32(ddlState.SelectedItem.Value.ToString());
                string Zip = txtZip.Text.Trim().ToString();
                string Fax = txtFax.Text.Trim().ToString();
                string Phone = txtPhone.Text.Trim().ToString();
                string Url = txtUrl.Text.Trim().ToString();
                int CeebNum = Convert.ToInt32(txtCeeb.Text.Trim());
                string Type = txtType.Text.Trim().ToString();
                string Level = txtLevel.Text.Trim().ToString();

                //schoolAdd.MinGrade = Convert.ToInt32(ddlMinGrade.SelectedItem.Value);
                //schoolAdd.MaxGrade = Convert.ToInt32(ddlMaxGrade.SelectedItem.Value);
                string PostZip = txtPostboxZip.Text.Trim().ToString();
                int PostState = Convert.ToInt32(ddlPostBoxState.SelectedItem.Value.ToString());
                string PostCity = txtPostboxCity.Text.Trim().ToString();
                string PostBox = txtPostbox.Text.Trim().ToString();
                string EmerPhone = txtEmer.Text.Trim().ToString();
                //schoolAdd.LastUpdated = DateTime.Now.ToShortDateString();
                string LastUpdated = DateTime.Now.ToString("MM/dd/yyyy", DateTimeFormatInfo.InvariantInfo);
                string Email = txtEmail.Text.Trim().ToString();
                string Principal = txtPrincipal.Text.Trim().ToString();
                string BaseGradeScale = txtGradingScale.Text.Trim().ToString();
                int Country = Convert.ToInt32(ddlCountry.SelectedItem.Value);

                string PostBoxAddress1 = txtPostBoxAddress1.Text.ToString().Trim();
                string PostBoxAddress2 = txtPostBoxAddress2.Text.ToString().Trim();
                int PostBoxCountry = Convert.ToInt32(ddlPostBoxCountry.SelectedItem.Value);

                //if (schoolAdd.MinGrade > schoolAdd.MaxGrade)
                //{
                //    lblerrmsg.Visible = true;
                //    lblerrmsg.Text = "Min grade less than Max grade";
                //    ModalPopupExtender2.Show();
                //    ModalPopupExtender2.Enabled = true;
                //    return;
                //}
                //else
                //{
                //    lblerrmsg.Visible = false;
                //    lblerrmsg.Text = "";
                //}
                //int Mingrade = 0;
                //int MaxGrade = 0;

                schoolAdd.SchoolAdd(ShortName, SchoolName, Address1, Address2, City, State, Zip, Fax, Phone, Url, CeebNum, Type, Level, PostZip, PostState, PostCity, PostBox, EmerPhone, LastUpdated, Email, Principal, BaseGradeScale, Country, PostBoxAddress1, PostBoxAddress2, PostBoxCountry);



                int Schoolid = schoolAdd.MaxSchoolID();

                   DataTable dtDateFormat = INBL.getdateformat();
                    if (dtDateFormat.Rows.Count > 0)
                   {
                       SISInstall.CalenderDateFormat = dtDateFormat.Rows[0][0].ToString();
                   }


                string BeginDate = DateTime.Now.ToString(SISInstall.CalenderDateFormat, DateTimeFormatInfo.InvariantInfo);
               string EndDate = DateTime.Now.ToString(SISInstall.CalenderDateFormat, DateTimeFormatInfo.InvariantInfo);


               // string BeginDate = DateTime.Now.ToString("MM/dd/yyyy", DateTimeFormatInfo.InvariantInfo);
               // string EndDate = DateTime.Now.ToString("MM/dd/yyyy", DateTimeFormatInfo.InvariantInfo);
                
               // int Schoolid = schoolAdd.SchoolID;

                DateTime beginyr = DateTime.Now;

                string beginyear = beginyr.Year.ToString(DateTimeFormatInfo.InvariantInfo);

                DateTime endyr = DateTime.Now;

                string endyear = endyr.Year.ToString(DateTimeFormatInfo.InvariantInfo);

                string SchoolYearName = beginyear + "-" + endyear;



                string Language = Session["MLCulture"].ToString();
                int Schoolyrid = INBL.InsertBeginEndDateschooladd(BeginDate,EndDate,SchoolYearName);


                INBL.InsertBeginEndDateintomarkinschooladd(BeginDate,EndDate,Schoolid,Schoolyrid);


                //*************** Grade Max ***********************
                //*************** Update on 28/04/2010*************
                    //string GradeLevelShortName = txtMaxGrade.Text;
                    ////GLBL.School_Id = schoolAdd.SchoolID;
                    //GLBL.AddGradeLevel(Schoolid,"",GradeLevelShortName,0,LastUpdated);
                    //int Maxgrade = GLBL.PopulateMaxGradeLevelID(Schoolid);
                    ////schoolAdd.MaxGrade = GLBL.GrdLevelId;
                    //schoolAdd.UpdateMaxGrade(Maxgrade,Schoolid);

                //*************** Grade Min *********************
                //*************** Update on 28/04/2010**************
                   //GradeLevelShortName = txtMinGrade.Text;
                   ////GLBL.School_Id = schoolAdd.SchoolID;
                   //GLBL.AddGradeLevel(Schoolid, "", GradeLevelShortName, 0, LastUpdated);
                   //int MinGrade =  GLBL.PopulateMaxGradeLevelID(Schoolid);
                   ////schoolAdd.MinGrade = GLBL.GrdLevelId;
                   //schoolAdd.UpdateMinGrade(MinGrade, Schoolid);

                //******************************************

                INBL.InsertintoSchoolspeccataddInstall(Schoolid);

                //*******************Ethnicity(17/05/2010)*******************
                INBL.InsertintoSchoolSpecificEthnicity(Schoolid);


                //************************************************

                 hdnschoolid.Value = Schoolid.ToString();
               // ddlSchoolName = (DropDownList)Page.Master.FindControl("ddlSchoolName");
              Session["SchoolID"] =  schoolAdd.MaxSchoolID();
               // schoolAdd.propulateSchool(ref ddlSchoolName);
               // ddlSchoolName.Items.FindByValue(schoolAdd.SchoolID.ToString()).Selected = true;
                Multiview1.ActiveViewIndex = 0;
                PupulateSchoolDetailsForView(Convert.ToInt32(Session["SchoolID"]));

                //Session["SchoolID"] = ddlSchoolName.SelectedItem.Value;

                //    Func.ResetFormControlValues(this.Page);
            }
            catch
            {

            }
            finally
            {
                //schoolAdd = null;
                //Func = null;
                schoolAdd.Close();
                INBL.Close();
                GLBL.Close();
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {

            // SchoolBL schoolEdit = new SchoolBL();
            OpenSISWCFServiceSchoolDetailsClient schoolEdit = new OpenSISWCFServiceSchoolDetailsClient();
            // Function Func = new Function();
            try
            {
                string ShortName = txtShortNameEdit.Text.Trim().ToString();
                string SchoolName = txtSchoolNameEdit.Text.Trim().ToString();
                string Address1 = txtAddress1Edit.Text.Trim().ToString();
                string Address2 = txtAddress2Edit.Text.Trim().ToString();
                string City = txtCityEdit.Text.Trim().ToString();
                int State = Convert.ToInt32(ddlStateEdit.SelectedItem.Value);
                string Zip = txtZipEdit.Text.Trim().ToString();
                string Fax = txtFaxEdit.Text.Trim().ToString();
                string Phone = txtPhoneEdit.Text.Trim().ToString();
                string Url = txtUrlEdit.Text.Trim().ToString();
                int CeebNum = Convert.ToInt32(txtCeebEdit.Text.Trim());
                string Type = txtTypeEdit.Text.Trim().ToString();
                string Level = txtLevelEdit.Text.Trim().ToString();
                //****************Update on 28/04/2010************************
                //int MinGrade = Convert.ToInt32(ddlMinGradeEdit.SelectedItem.Value);
                //int MaxGrade = Convert.ToInt32(ddlMaxGradeEdit.SelectedItem.Value);
                //***************************************************************
                string PostZip = txtPostBoxZipEdit.Text.Trim().ToString();
                int PostState = Convert.ToInt32(ddlPostBoxStateEdit.SelectedItem.Value);
                string PostCity = txtPostBoxCityEdit.Text.Trim().ToString();
                string PostBox = txtPostBoxEdit.Text.Trim().ToString();
                string EmerPhone = txtEmerEdit.Text.Trim().ToString();
                string LastUpdated = DateTime.Now.ToString("MM/dd/yyyy", DateTimeFormatInfo.InvariantInfo);

                //int SchoolID = Convert.ToInt32(ddlSchoolName.SelectedItem.Value);
                int SchoolID = Convert.ToInt32(Session["SchoolID"]);
                string Email = txtEmailEdit.Text.Trim().ToString();
                string Principal = txtPrincipalEdit.Text.Trim().ToString();
                string BaseGradeScale = txtGradeScaleEdit.Text.Trim().ToString();
                int Country = Convert.ToInt32(ddlCountryEdit.SelectedItem.Value);



                string PostBoxAddress1 = txtPostBoxAddress1Edit.Text.ToString().Trim();
                string PostBoxAddress2 = txtPostBoxAddress2Edit.Text.ToString().Trim();
                int PostBoxCountry = Convert.ToInt32(ddlcountrymledit.SelectedItem.Value);


                //if (schoolEdit.MinGrade > schoolEdit.MaxGrade)
                //{
                //    lblerrmsgedit.Visible = true;
                //    lblerrmsgedit.Text = "Min grade less than Max grade";
                //    ModalPopupExtenderEdit.Show();
                //    ModalPopupExtenderEdit.Enabled = true;
                //    return;
                //}
                //else
                //{
                //    lblerrmsgedit.Visible = false;
                //    lblerrmsgedit.Text = "";
                //}


                schoolEdit.SchoolEdit(ShortName, SchoolName, Address1, Address2, City, State, Zip, Fax, Phone, Url, CeebNum, Type, Level, PostZip, PostState, PostCity, PostBox, EmerPhone, LastUpdated, Email, Principal, BaseGradeScale, Country, PostBoxAddress1, PostBoxAddress2, PostBoxCountry, SchoolID);

                //PopulateMasterDropdown();

                // Func.ResetFormControlValues(this.Page);

                // ddlSchoolName.Items.FindByValue(schoolEdit.SchoolID.ToString()).Selected = true;
                Multiview1.ActiveViewIndex = 0;
                // PupulateSchoolDetailsForView(Convert.ToInt32(ddlSchoolName.SelectedItem.Value));
                PupulateSchoolDetailsForView(SchoolID);
                ModalPopupExtenderEdit.Enabled = false;
                // Session["SchoolID"] = ddlSchoolName.SelectedItem.Value;
            }
            catch
            {

            }
            finally
            {
                // schoolEdit = null;
                // Func = null;
                schoolEdit.Close();
            }
        }

        private void PupulateSchoolDetailsForEdit(int Schoolid)
        {
            OpenSISWCFServiceSchoolDetailsClient schoolAdd = new OpenSISWCFServiceSchoolDetailsClient();
            try
            {
                //   schoolAdd.SchoolID = Schoolid;


                //******************Update on 28/04/2010***********
                //propulate(ref ddlMinGradeEdit);
                //propulate(ref ddlMaxGradeEdit);
                //**********************************************
                propulateState(ref ddlStateEdit);
                propulateState(ref ddlPostBoxStateEdit);
                propulateCountry(ref ddlCountryEdit, ref ddlcountrymledit);
                // propulateCountry(ref ddlcountrymledit);

                DataTable dt = schoolAdd.GetvalufromID(Schoolid);

                if (dt.Rows.Count > 0)
                {


                    txtSchoolNameEdit.Text = dt.Rows[0]["sch_full_nm"].ToString().Trim();
                    txtShortNameEdit.Text = dt.Rows[0]["sch_short_nm"].ToString().Trim();
                    txtAddress1Edit.Text = dt.Rows[0]["sch_addr1"].ToString().Trim();
                    txtAddress2Edit.Text = dt.Rows[0]["sch_addr2"].ToString().Trim();
                    txtCityEdit.Text = dt.Rows[0]["sch_city"].ToString().Trim();
                    string StateName = dt.Rows[0]["State"].ToString().Trim();
                    if (StateName != "")
                    {
                        ddlStateEdit.Items.FindByText(StateName).Selected = true;
                    }
                    txtZipEdit.Text = dt.Rows[0]["sch_zip"].ToString().Trim();
                    txtFaxEdit.Text = dt.Rows[0]["sch_fax"].ToString().Trim();
                    txtPhoneEdit.Text = dt.Rows[0]["sch_phn"].ToString().Trim();
                    txtUrlEdit.Text = dt.Rows[0]["sch_url"].ToString().Trim();
                    txtCeebEdit.Text = Convert.ToInt32(dt.Rows[0]["sch_ceeb_nbr"]).ToString();
                    txtTypeEdit.Text = dt.Rows[0]["sch_type"].ToString().Trim();
                    txtLevelEdit.Text = dt.Rows[0]["sch_ed_lvl"].ToString().Trim();
                    //***************Update on 28/04/2010****************************
                    //ddlMaxGradeEdit.Items.FindByValue(Convert.ToInt32(dt.Rows[0]["sch_max_grade_id"]).ToString()).Selected = true;
                    //ddlMinGradeEdit.Items.FindByValue(Convert.ToInt32(dt.Rows[0]["sch_min_grade_id"]).ToString()).Selected = true;
                    //**************************************************************
                    txtPostBoxZipEdit.Text = dt.Rows[0]["sch_po_box_zip"].ToString().Trim();
                    string PostBoxState = dt.Rows[0]["PostState"].ToString().Trim();
                    if (PostBoxState != "")
                    {
                        ddlPostBoxStateEdit.Items.FindByText(PostBoxState).Selected = true;
                    }
                    txtPostBoxCityEdit.Text = dt.Rows[0]["sch_po_box_city"].ToString().Trim();
                    txtPostBoxEdit.Text = dt.Rows[0]["sch_po_box"].ToString().Trim();
                    txtEmerEdit.Text = dt.Rows[0]["sch_emer_phn"].ToString().Trim();
                    txtEmailEdit.Text = dt.Rows[0]["sch_email"].ToString().Trim();
                    txtPrincipalEdit.Text = dt.Rows[0]["sch_principal"].ToString().Trim();
                    txtGradeScaleEdit.Text = dt.Rows[0]["sch_base_grading_scale"].ToString().Trim();
                    string CountryName = dt.Rows[0]["Country"].ToString().Trim();
                    if (CountryName != "")
                    {
                        ddlCountryEdit.Items.FindByText(CountryName).Selected = true;
                    }

                    string PostCountryName = dt.Rows[0]["PostCountry"].ToString().Trim();
                    if (PostCountryName != "")
                    {
                        ddlcountrymledit.Items.FindByText(PostCountryName).Selected = true;
                    }

                    txtPostBoxAddress1Edit.Text = dt.Rows[0]["sch_po_box_addr1"].ToString().Trim();
                    txtPostBoxAddress2Edit.Text = dt.Rows[0]["sch_po_box_addr2"].ToString().Trim();
                }
            }
            catch
            {
            }
            finally
            {
                //schoolAdd = null;
                schoolAdd.Close();
            }
        }

        //private void PupulateSchoolDetailsForView(int Schoolid)
        //{
        //   // SchoolBL schoolAdd = new SchoolBL();
        //    ServicePropertiesClient schoolAdd = new ServicePropertiesClient();
        //    try
        //    {
        //        int SchoolID = Schoolid;
        //        schoolAdd.GetvalufromID();
        //        lblSchoolName.Text = schoolAdd.shortyh;
        //        lblShortName.Text = schoolAdd.ShortName;
        //        lblAddress1.Text = schoolAdd.Address1;
        //        lblAddress2.Text = schoolAdd.Address2;
        //        lblCity.Text = schoolAdd.City;
        //        lblState.Text = schoolAdd.StateName;
        //        lblZip.Text = schoolAdd.Zip;
        //        lblFax.Text = schoolAdd.Fax;
        //        lblPhone.Text = schoolAdd.Phone;
        //        lblUrl.Text = schoolAdd.Url;
        //        lblCeeb.Text = schoolAdd.CeebNum.ToString();
        //        if (lblCeeb.Text == "0")
        //        {
        //            lblCeeb.Text = "";
        //        }
        //        lblType.Text = schoolAdd.Type;
        //        lblLevel.Text = schoolAdd.Level;
        //        lblMaxGrade.Text = schoolAdd.MaxGradeName.ToString();
        //        lblMinGrade.Text = schoolAdd.MinGradeName.ToString();
        //        lblPBZip.Text = schoolAdd.PostZip;
        //        lblPBState.Text = schoolAdd.PostStateName;
        //        lblPBCity.Text = schoolAdd.PostCity;
        //        lblPostBox.Text = schoolAdd.PostBox;
        //        lblEmerPhone.Text = schoolAdd.EmerPhone;
        //        lblPrincipal.Text = schoolAdd.Principal;
        //        lblEmail.Text = schoolAdd.Email;
        //        lblGradingScale.Text = schoolAdd.BaseGradeScale;
        //        lblCountry.Text = schoolAdd.CountryName;

        //        lblPostBoxAddress1.Text = schoolAdd.PostBoxAddress1;
        //        lblPostBoxAddress2.Text = schoolAdd.PostBoxAddress2;
        //        lblPostBoxCountry.Text = schoolAdd.PostCountryName;
        //    }
        //    catch
        //    {
        //    }
        //    finally
        //    {
        //        schoolAdd = null;
        //    }
        //}



        private void PupulateSchoolDetailsForView(int Schoolid)
        {
            // SchoolBL schoolAdd = new SchoolBL();
            //ServicePropertiesClient schoolAdd = new ServicePropertiesClient();

            OpenSISWCFServiceSchoolDetailsClient schoolAdd = new OpenSISWCFServiceSchoolDetailsClient();

            try
            {
                int SchoolID = Schoolid;
                DataTable dt = schoolAdd.GetvalufromID(Schoolid);




                if (dt.Rows.Count > 0)
                {
                    lblSchoolName.Text = dt.Rows[0]["sch_full_nm"].ToString().Trim();
                    lblShortName.Text = dt.Rows[0]["sch_short_nm"].ToString().Trim();
                    lblAddress1.Text = dt.Rows[0]["sch_addr1"].ToString().Trim();
                    lblAddress2.Text = dt.Rows[0]["sch_addr2"].ToString().Trim();
                    lblCity.Text = dt.Rows[0]["sch_city"].ToString().Trim();
                    lblState.Text = dt.Rows[0]["State"].ToString().Trim();
                    lblZip.Text = dt.Rows[0]["sch_zip"].ToString().Trim();
                    lblFax.Text = dt.Rows[0]["sch_fax"].ToString().Trim();
                    lblPhone.Text = dt.Rows[0]["sch_phn"].ToString().Trim();
                    lblUrl.Text = dt.Rows[0]["sch_url"].ToString().Trim();
                    lblCeeb.Text = Convert.ToInt32(dt.Rows[0]["sch_ceeb_nbr"]).ToString();
                    if (lblCeeb.Text == "0")
                    {
                        lblCeeb.Text = "";
                    }
                    lblType.Text = dt.Rows[0]["sch_type"].ToString().Trim();
                    lblLevel.Text = dt.Rows[0]["sch_ed_lvl"].ToString().Trim();
                    //******** Update on 28/04/2010****************************
                    //lblMaxGrade.Text = dt.Rows[0]["MaxGrade"].ToString().Trim();
                    //lblMinGrade.Text = dt.Rows[0]["MinGrade"].ToString().Trim(); 
                    //*********************************************************
                    lblPBZip.Text = dt.Rows[0]["sch_po_box_zip"].ToString().Trim();
                    lblPBState.Text = dt.Rows[0]["PostState"].ToString().Trim();
                    lblPBCity.Text = dt.Rows[0]["sch_po_box_city"].ToString().Trim();
                    lblPostBox.Text = dt.Rows[0]["sch_po_box"].ToString().Trim();
                    lblEmerPhone.Text = dt.Rows[0]["sch_emer_phn"].ToString().Trim();
                    lblPrincipal.Text = dt.Rows[0]["sch_principal"].ToString().Trim();
                    lblEmail.Text = dt.Rows[0]["sch_email"].ToString().Trim();
                    lblGradingScale.Text = dt.Rows[0]["sch_base_grading_scale"].ToString().Trim();
                    lblCountry.Text = dt.Rows[0]["Country"].ToString().Trim();

                    lblPostBoxAddress1.Text = dt.Rows[0]["sch_po_box_addr1"].ToString().Trim();
                    lblPostBoxAddress2.Text = dt.Rows[0]["sch_po_box_addr2"].ToString().Trim();
                    lblPostBoxCountry.Text = dt.Rows[0]["PostCountry"].ToString().Trim();
                }
            }
            catch
            {
            }
            finally
            {
                // schoolAdd = null;
                schoolAdd.Close();
            }
        }




        protected void btnUpdateCancel_Click(object sender, EventArgs e)
        {
            //Function Func = new Function();
            //SchoolBL schoolEdit = new SchoolBL();s
            //try
            //{


            //    Func.ResetFormControlValues(this.Page);


            //    Multiview1.ActiveViewIndex = 0;
            //    PupulateSchoolDetailsForView(Convert.ToInt32(ddlSchoolName.SelectedItem.Value));
            //    ModalPopupExtenderEdit.Enabled = false;
            //}
            //catch
            //{
            //}
            //finally
            //{
            //    Func = null;
            //    schoolEdit = null;
            //}

        }

        protected void PopulateMasterDropdown()
        {
            //SchoolBL schoolAdd = new SchoolBL();
            //try
            //{
            //    ddlSchoolName = (DropDownList)Page.Master.FindControl("ddlSchoolName");
            //    ddlSchoolName.Items.Clear();
            //    schoolAdd.propulateSchool(ref ddlSchoolName);
            //    ddlSchoolName.SelectedIndexChanged += new EventHandler(ddlSchoolName_SelectedIndexChanged);
            //    ddlSchoolName.AutoPostBack = true;
            //    ddlSchoolName.Style.Add("font-family", "Arial Unicode MS");
            //}
            //catch
            //{

            //}
            //finally
            //{
            //    schoolAdd = null;
            //}
        }

        protected void ddlSchoolName_SelectedIndexChanged(object sender, EventArgs e)
        {
            //SchoolBL schoolAdd = new SchoolBL();
            //Multiview1.ActiveViewIndex = 0;
            //ddlSchoolName = (DropDownList)Page.Master.FindControl("ddlSchoolName");
            //hdnschoolid.Value = ddlSchoolName.SelectedItem.Value;
            //Session["SchoolID"] = ddlSchoolName.SelectedItem.Value;
            //PupulateSchoolDetailsForView(Convert.ToInt32(ddlSchoolName.SelectedItem.Value));
            //PopulateMasterDropdownFullYear();
        }

        protected void imgBtnEdit_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                PupulateSchoolDetailsForEdit(Convert.ToInt32(Session["SchoolID"]));
                lblerrmsgedit.Text = "";
                ModalPopupExtenderEdit.Enabled = true;
                ModalPopupExtenderEdit.Show();
            }
            catch
            {
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            //Function Func = new Function();
            //try
            //{
            //    Func.ResetFormControlValues(this.Page);
            //}
            //catch
            //{
            //}
            //finally
            //{
            //    Func = null;
            //}
        }


        public void propulateState(ref DropDownList ddl)
        {
            ServicePropertiesClient SCBL = new ServicePropertiesClient();

            DataSet ds = null;
            ds = SCBL.propulateState();

            ddl.Items.Clear();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "NAME";
            ddl.DataValueField = "IID";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));
            SCBL.Close();
        }

        public void propulateCountry(ref DropDownList ddl, ref DropDownList ddl1)
        {
            ServicePropertiesClient scDl = new ServicePropertiesClient();

            DataSet ds = null;
            ds = scDl.propulateCountry();

            ddl.Items.Clear();
            ddl.DataSource = ds.Tables[0];
            ddl.DataTextField = "NAME";
            ddl.DataValueField = "IID";
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));


            ddl1.Items.Clear();
            ddl1.DataSource = ds.Tables[0];
            ddl1.DataTextField = "NAME";
            ddl1.DataValueField = "IID";
            ddl1.DataBind();
            ddl1.Items.Insert(0, new ListItem("Select", "0"));

            scDl.Close();

        }
        public void propulate(ref DropDownList ddl)
        {
            OpenSISWCFServiceSchoolDetailsClient scDl = new OpenSISWCFServiceSchoolDetailsClient();

            DataSet ds = null;
            int SchoolId = Convert.ToInt32(Session["SchoolID"]);
            ds = scDl.propulate(SchoolId);

            ddl.Items.Clear();
            ddl.DataSource = ds.Tables[0];

            ddl.DataTextField = "grd_lvl_short_nm";//saikat----14/5/09
            ddl.DataValueField = "grd_lvl_id";//saikat----14/5/09
            ddl.DataBind();
            ddl.Items.Insert(0, new ListItem("Select", "0"));
            scDl.Close();
        }

        private void ml_InitCulture()
        {

            String MLCultureName = (String)Session["MLCulture"];
            String MLUICultureName = (String)Session["MLUICulture"];

            if ((MLCultureName != null) && (MLCultureName.Length > 0))
            {
                Page.Culture = MLCultureName;
            }

            if ((MLUICultureName != null) && (MLUICultureName.Length > 0))
            {
                Page.UICulture = MLUICultureName;
            }
        }

        protected override void InitializeCulture()
        {
            ml_InitCulture();
        }

    }
}